<?php
include '../phpFunctions/databaseConnect.php';
$result = mysql_query("select pictureURL from items,users where username='$itemUsername' and user=user_id");
                 $i=0;
                 while($row = mysql_fetch_assoc($result))  {
                        $pictureURL = $row["pictureURL"];
                        $pictureURLArray[$i] = $pictureURL;
                        ++$i;
                        }

$result = mysql_query("select item_id from items i, users u where i.user=u.user_id and u.username= '$itemUsername'  order by item_id");
                 $i=0;
                 while($row = mysql_fetch_assoc($result))  {
                        $itemId = $row["item_id"];
                        $itemIdArray[$i] = $itemId;
                        ++$i;
                        }



 mysql_close();

    echo "<center>";
    $i=0;
    $url1 = '../Bildgalleri/showItem.php';
    while($i<count($pictureURLArray) && $i<5) {
        $randomInt = rand_except(1, count($pictureURLArray), $exceptThese);
        $exceptThese[$i] = $randomInt;

        //function returns a random integer between min and max, just like function rand() does.
  // Difference to rand is that the random generated number will not use any of the values
  // placed in $except. ($except must therefore be an array)
  // function returns false if $except holds all values between $min and $max.



        $picURL = $pictureURLArray[$randomInt];

        echo "<a href='", $url1, '?itemID=' . $itemIdArray[$randomInt] . "' <img src='../Bildgalleri/Paintings/$picURL' width='110' height='110' />";
        echo "  ";
        ++$i;
       }
       echo "</center>";

?>